package mypackage;

import java.util.ArrayList;
import java.util.List;

public class Test2 {

    public static void main(String[] args) {
        //f1();
        //f2();
        //f3();
        //f4();

        //String str = "hello world!";
        //str =  str.replace("h","xx");
        //System.out.println("str = " + str);

        //double d = 0;
        //System.out.println("d = " + d); // d = 0.0

        //f5();

        f6();
    }

    private static void f6() {
        Test2 test2 = new Test2();
        Class<? extends Test2> aClass = test2.getClass();
        System.out.println("aClass = " + aClass);

        Class<MyInterface> myInterfaceClass = MyInterface.class;
        System.out.println("myInterfaceClass = " + myInterfaceClass);

        double[] intArr = new double[3];
        System.out.println("intArr.getClass() = " + intArr.getClass());

        System.out.println(MyEnum.class);

        System.out.println(long.class);

        System.out.println(void.class);

    }

    private static void f5() {
        char ch = '\u0000';
        System.out.println(ch);
    }

    private static void f4() {
        String classPath = "java.util.Map<java.lang.String,java.lang.String>";
        String substring = classPath.substring(0, classPath.indexOf("<"));
        System.out.println("substring = " + substring);
    }

    private static void f3() {
        String classPath = "java.util.Map<java.lang.String,java.lang.String>";
        if(classPath.contains("<")){
            String key = classPath.substring(classPath.indexOf("<") + 1, classPath.indexOf(","));
            String value = classPath.substring(classPath.indexOf(",")+1, classPath.length() - 1);
            System.out.println("key = " + key);
            System.out.println("value = " + value);

        }
    }

    private static void f1() {
        String classPath = "java.util.List<java.lang.String>";
        if(classPath.contains("<")){
            int i = classPath.indexOf("<");
            String substring = classPath.substring(classPath.indexOf("<")+1, classPath.length()-1);
            System.out.println("substring = " + substring);
            String substring1 = classPath.substring(0, classPath.indexOf("<"));
            System.out.println("substring1 = " + substring1);
        }
    }

    private static void f2() {
        List<String> list = new ArrayList<>();
        list.add("boolean add(E)");
        list.add("E remove(int)");

        List<String> newList = new ArrayList<>();
        for (String str : list) {
            if(str.contains("E")){
                String newStr = str.replace("E", "java.lang.String");
                newList.add(newStr);
            }else {
                newList.add(str);
            }
        }

        newList.stream().forEach(System.out::println);
    }
}

interface MyInterface{
    public static final String str = "xxx";
}

enum MyEnum{
    RED;
}